package leading;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;

/*
 * map.entrySet返回一个视图 key = value
 * Map.Entry<String, String> = map.entrySet()
 */
public class HashMapTest {
	public static void main(String[] args) {
		Map<String, String> tMap = new HashMap<String, String>();
		tMap.put("che","车");
		tMap.put("wen", "文");
		tMap.put("liang", "亮");
		
/*		if(tMap.containsKey("che")){
			System.out.println(tMap.get("che"));
		}
		if(tMap.containsValue("亮")){
			System.out.println("有亮");
		}
		Iterator iter = tMap.values().iterator();
		while(iter.hasNext()){
			System.out.println(iter.next());
		}*/
		Iterator<Map.Entry<String, String>> entry = tMap.entrySet().iterator();
		while(entry.hasNext()){
			Entry<String, String> value = entry.next();
			String tKey = value.getKey();
			String tValue = value.getValue();
			
			System.out.println(tKey + ":" + tValue);
			//System.out.println(entry.next().getKey());
		}
	}
}
